<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			function customSplit(str, separator) {
				let result = [];
				let start = 0;
				for (let i = 0; i < str.length; i++) {
					if (str[i] === separator) {
						result.push(str.substring(start, i));
						start = i + 1;
					}
				}
				result.push(str.substring(start)); // 添加最后一个片段
				return result;
			}
			// 示例使用
			const myString = "apple,banana,cherry";
			const myArray = customSplit(myString, ",");
			console.log(myArray); // 输出: ["apple", "banana", "cherry"]
		</script>
	</body>
</html>